//
// [Author] lg (https://github.com/lemos1235)
// [Date] 2025/5/4
//
import 'package:flutter/material.dart';
import 'package:forui/forui.dart';
import 'package:icoffee/widgets/number_statistic.dart';

class HomeScreen extends StatefulWidget {
  const HomeScreen({super.key});

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 2,
      child: Scaffold(
        body: FScaffold(
          childPad: false,
          header: FHeader.nested(title: Text("咖啡日记")),
          child: Column(
            children: [
              Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  FDivider(
                    style: context.theme.dividerStyles.horizontalStyle.copyWith(
                      padding: EdgeInsets.only(top: 0, bottom: 4),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10),
                    child: Row(
                      children: [
                        NumberStatistic(title: "冲煮次数", value: "2", suffix: "次"),
                        const FDivider(axis: Axis.vertical),
                        NumberStatistic(title: "豆种", value: "1", suffix: "种"),
                        const FDivider(axis: Axis.vertical),
                        NumberStatistic(
                          title: "剩余",
                          value: "30.0",
                          suffix: "克",
                        ),
                        const FDivider(axis: Axis.vertical),
                        NumberStatistic(
                          title: "距上次使用",
                          value: "150",
                          suffix: "天",
                        ),
                      ],
                    ),
                  ),
                  FDivider(
                    style: context.theme.dividerStyles.horizontalStyle.copyWith(
                      padding: EdgeInsets.symmetric(vertical: 4),
                    ),
                  ),
                  TabBar(
                    tabs: [Tab(text: "饮用记录"), Tab(text: "冷萃记录")],
                    dividerColor: Colors.transparent,
                  ),
                ],
              ),
              Expanded(
                child: TabBarView(
                  children: [_buildDrinkRecord(), _buildColdBrewRecord()],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget _buildDrinkRecord() {
    return Container(
      color: Color(0xFFF9F9F9),
      padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10),
      child: Center(child: Text("开始您的品咖之旅吧~")),
    );
  }

  Widget _buildColdBrewRecord() {
    return Container(
      color: Color(0xFFF9F9F9),
      child: Center(child: Text("开始您的品咖之旅吧~")),
    );
  }
}
